package cn.pzhu.pserson.dto;

import javax.validation.constraints.Min;

/**
 *
 * 限制条数的DTO
 * */
public class LimitShowDTO {
    @Min(value=1)
    private int pageNum = 1;
    // 限制默认为-1，如果为-1不需要限制
    @Min(value=-1)
    private int pageSize = -1;


    public int getPageNum() {
        return pageNum;
    }

    public void setPageNum(int pageNum) {
        this.pageNum = pageNum;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }


    /**
     * 计算开始
     * */
    public int calculateStart() {
        return pageSize < 0 ? -1 : (pageNum - 1) * pageSize;
    }

    /**
     * 计算结束
     * */
    public int calculateEnd() {
        return pageSize < 0 ? -1 : pageNum * pageSize;
    }

}
